package cn.itcast.bos.web.action.system;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.domain.system.Role;
import cn.itcast.bos.domain.utils.BaseAction;
import cn.itcast.bos.service.system.RoleService;

@Namespace("/")
@ParentPackage("json-default")
@Controller
@Scope("prototype")
public class RoleAction extends BaseAction<Role> {

	@Autowired
	private RoleService roleService;

	@Action(value = "role_list", results = { @Result(name = "success", type = "json") })
	public String role_list() {

		List<Role> roles = roleService.finAll();
		ServletActionContext.getContext().getValueStack().push(roles);

		return SUCCESS;
	}
	

	
	
	@Action(value="role_save",results={@Result(name="success",type="redirect",location="/pages/system/role.html")})
	public String role_save(){
		roleService.save(model,menuIds,permissionIds);
		
		return SUCCESS;
	}

	private String menuIds;

	public void setMenuIds(String menuIds) {
		this.menuIds = menuIds;
	}
	
	private String[] permissionIds;

	public void setPermissionIds(String[] permissionIds) {
		this.permissionIds = permissionIds;
	}



}
